<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #btn{
            width: 100px;
            height: 100px;
            background: pink;
            cursor: pointer;
        }
        #btn div{
            background: red;
            width: 50px;
            height: 50px;
        }
    </style>
</head>
<body>

<div id="btn">
    <div id="btn2"></div>
</div>

</body>

<script>

    btn.onclick = function () {
        console.log(1)
    }

    btn2.onclick = function (e) {
        e.stopPropagation() //阻止冒泡
        console.log(2)
    }


    //阻止鼠标右键
    document.oncontextmenu = function () {
        return false
    }


</script>

</html>